const jql = require('jql')
const result = require('result')

module.exports = {
  _before() {
    //在this中存入db对象
    this.db = jql(this, 'commodity')
  },
  //搜索商品
  async searchCommodity(name) {
    //模糊查询商品名称
    const res = await this.db
      .where(`/${name}/.test(name)`)
      .get()
    
    return result.success(res.data)
  }
}
